home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14628 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  40 lines

  1. Newsgroups: comp.lang.c++,de.comp.lang.c++
  2. Path: Dortmund.Germany.EU.net!oerag!snark!KEN
  3. From: KEN@oerag.de (Karsten Ensinger)
  4. Subject: Re: Another function pointer from a class question?!
  5. References: <4jls2p$bac@pulp.ucs.ualberta.ca>
  6. Date: 01 Apr 1996 14:14:05 GMT
  7. Message-ID: <KEN.96Apr01141405@oerag.de>
  8. In-reply-to: ryangall@gpu.srv.ualberta.ca's message of 31 Mar 1996 11:59:21 GMT
  9. X-NNTPDaemon: changi 0.9 for OS/2
  10.  
  11. Hi Ryan!
  12.  
  13. First: you can not redefine Remove as a function taking NO argument.
  14. In list: virtual T Remove(T)=0;
  15. In dl_list: T Remove(); -> This hides the virtual T Remove(T)!
  16.  
  17. Second: the return value of list<T>::Add(T) is "T" but the return
  18. value of dl_list<T>::Add(T) is "int". Same problem as "First:" if
  19. you use dl_list<T> with types other than int.
  20.  
  21. Third: you have to implement ALL pure virtual functions of your
  22. baseclass (list) if you want to create a object of this
  23. class (dl_list).
  24. So you have to implement in dl_list also "int isempty()" and
  25. "int Inlist(T)". If you don't (and you didn't ;-)) you have another
  26. abstract class which cannot be created. This is what the compiler
  27. complains about "abstract class".
  28.  
  29. The error message of the linker is caused by NOT inheriting from
  30. list<T> but implementing only "list<T>::print(...)". You should
  31. also implement "dl_list<T>::print(...)".
  32.  
  33. My suggestion is:
  34. try to implement ALL methods of list<T> in dl_list<T> and always
  35. have a look at the warnings of the compiler. For a beginner I
  36. would recommend to use a high warning level (but not the highest!).
  37.  
  38. Regards
  39. Karsten
  40.